from flask_restful import Resource
from flask_login import login_required
from app import app, db
from models import Image


class ImageApi(Resource):
    method_decorators = [login_required]

    def get(self, id):
        app.logger.info('Get Image %d' % id)
        return {'Hello': 'get World %d' % id}

    def delete(self, id):
        app.logger.info('Delete Image %d' % id)
        image = Image.query.get(id)
        db.session.delete(image)
        db.session.commit()
        return {'success': True}

